
package phase2.rd;

import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * 
 * 
 * @author John Girata
 * @version Dec 5, 2012
 */
public class InteriorNode extends Node {
	private List<Node> children;
	
	public InteriorNode(String value, Node... children) {
		super(value);
		
		this.children = new ArrayList<>(Arrays.asList(children));
	}
	
	public void addChild(Node node) {
		children.add(node);
	}

	public List<Node> getChildren() {
		return children;
	}

	@Override
	public void print(PrintStream out) {
		StringBuilder builder = new StringBuilder();
		builder.append(getId() + VALUE_SEPARATOR + getValue());
		
		for (Node child : children) {
			child.print(out);
			builder.append(VALUE_SEPARATOR + child.getId());
		}
		
		out.println(builder.toString());
	}
}
